package com.thinkcube.edutainment.fragment;

import java.util.ArrayList;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.ViewById;

import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.thinkcube.edutainment.R;
import com.thinkcube.edutainment.adapters.IndexAdapter;
import com.thinkcube.edutainment.domain.data.CourseData;
@EFragment(R.layout.message_navigation_bar)
public class MessageNavigationsBar extends Fragment implements OnItemClickListener{

	
	@ViewById(R.id.list)
	ListView listview;
	
	IndexAdapter adapter;
	
	@AfterViews
	void setIndex()
	{
		ArrayList<String> indexes =new ArrayList<String>();
		indexes.add("Inbox");
		indexes.add("Sent");
		indexes.add("Draft");
		indexes.add("Notifications");
		
		adapter=new IndexAdapter(getActivity(), new String[indexes.size()], indexes);
		listview.setAdapter(adapter);
		listview.setOnItemClickListener(this);
		
	}
	


	CourseData courseData = new CourseData();

	@AfterViews
	void initUi() {
		
	}

	

	@Override
	public void onItemClick(AdapterView<?> arg0, View view, int position, long arg3) {
		System.out.println("mycourse"+position);
		FragmentTransaction fragmentTransaction = getFragmentManager()
				.beginTransaction();
		Bundle bundle = new Bundle();
		if(adapter!=null)
		{
			adapter.setSelectedItem(position);
		}
		
		switch (position) {
		case 0:
			MessageInbox inbox = new MessageInbox_();
			fragmentTransaction.replace(R.id.pane, inbox);
			fragmentTransaction.commit();
			break;
			
		case 1:
			
			SentBoxFragment sentbox = new SentBoxFragment_();
			sentbox.setArguments(bundle);
			fragmentTransaction.replace(R.id.pane, sentbox);
			fragmentTransaction.commit();
			break;
			
		case 2:
			DraftMessageFragment draftbox = new DraftMessageFragment_();
			fragmentTransaction.replace(R.id.pane, draftbox);
			fragmentTransaction.commit();
			break;
		case 3:
			Notifications packgeLontent = new Notifications_();
			fragmentTransaction.replace(R.id.pane, packgeLontent);
			fragmentTransaction.commit();
			break;

		default:
			break;
		}
	}


}
